<template>
	<view class="my-settle-container">
		<!-- 全选区域 -->
		<label class="radio">
			<radio color="#C00000" :checked="isAllCheck" @click="changeAllState"/><text>全选</text>
		</label>
		<!-- 合计区域 -->
		<view class="amount-box">
			合计:<text class="amount">￥{{checkedGoodsAmount}}</text>
		</view>
		<!-- 结算按钮 -->
		<view class="btn-settle">结算{{checkedCont}}</view>
	</view>
</template>

<script>
	import {
		mapGetters,mapMutations
	} from 'vuex'
	export default {
		name: "my-settle",
		data() {
			return {

			};
		},
		computed: {
			...mapGetters('mycart', ['checkedCont', 'total','checkedGoodsAmount']),
			// 判断购物车里所有的商品是否全选  [checkedCont是所有选中的商品数量]
			isAllCheck() {
				return this.total === this.checkedCont
			}
		},
		methods:{
			...mapMutations('mycart',['updateAllGoodsState',]),
			// 全选按钮的点击事件
			changeAllState() {
				// 修改购物车中所有商品的选中状态
				this.updateAllGoodsState(!this.isAllCheck)
			}
			
		},
	}
</script>

<style lang="scss">
	.my-settle-container {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 50px;
		background-color: white;
		display: flex;
		align-items: center;
		padding-left: 5px;
		justify-content: space-between;
		font-size: 14px;

		.radio {
			display: flex;
			align-items: center;
		}

		.amount {
			color: #c00000;
		}

		.btn-settle {
			height: 50px;
			min-width: 100px;
			background-color: #c00000;
			color: white;
			line-height: 50px;
			text-align: center;
			padding: 0 10px;
		}
	}
</style>